package com.vf.admin.miaodong.controller;

import com.vf.admin.common.BaseController;
import com.vf.admin.common.Constants;
import com.vf.admin.common.splitpage.SplitPageBean;
import com.vf.admin.miaodong.entity.AppMingXiZuanShi;
import com.vf.admin.miaodong.entity.AppMingxiJinbi;
import com.vf.admin.miaodong.entity.AppMingxiMeilizhi;
import com.vf.admin.miaodong.service.AfterMingXiZuanShiService;
import com.vf.admin.miaodong.service.AfterMingxiJinbiService;
import com.vf.admin.miaodong.service.AfterMingxiMeilizhiService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 收益明细
 */
@Controller
@RequestMapping("/after/mingxi")
public class AfterMingxiController extends BaseController{
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    AfterMingxiJinbiService afterMingxiJinbiService;
    @Autowired
    AfterMingxiMeilizhiService afterMingxiMeilizhiService;
    @Autowired
    AfterMingXiZuanShiService afterMingXiZuanShiService;

    /**
     * 金币明细
     * @param splitPageBean
     * @param startDate  开始时间
     * @param endDate  结束时间
     * @param nick  用户名称
     * @param phone  用户电话
     * @param giftname 礼物名称
     * @return
     */
    @RequestMapping("/jinbiList")
    public String list(SplitPageBean splitPageBean,String startDate,String endDate,String nick,String phone, String giftname){
        try{
            Map<String,Object> map = new HashMap<>();
            map.put("startDate",startDate);
            map.put("endDate",endDate);
            map.put("nick",nick);
            map.put("phone",phone);
            List<AppMingxiJinbi> list = afterMingxiJinbiService.findList(map,splitPageBean);
            //明细类型
            Map<Integer,String> mingxiMap = Constants.getMingxiMap();
            request.setAttribute("mingxiMap",mingxiMap);
            request.setAttribute("list",list);
            request.setAttribute("splitPage",splitPageBean);
            request.setAttribute("startDate",startDate);
            request.setAttribute("endDate",endDate);
            request.setAttribute("nick",nick);
            request.setAttribute("phone",phone);
            return this.sucess("/web/after/mingxi/jinbilist");
        }catch (Exception e){
            logger.error("收益明细列表异常",e);
            return this.error("系统繁忙");
        }
    }

    /**
     * 魅力值明细
     * @param splitPageBean
     * @param startDate  开始时间
     * @param endDate  结束时间
     * @param nick  用户名称
     * @param phone  用户电话
     * @param giftname 礼物名称
     * @return
     */
    @RequestMapping("/meilizhiList")
    public String meilizhiList(SplitPageBean splitPageBean,String startDate,String endDate,String nick,String phone, String giftname){
        try{
            Map<String,Object> map = new HashMap<>();
            map.put("startDate",startDate);
            map.put("endDate",endDate);
            map.put("nick",nick);
            map.put("phone",phone);
            List<AppMingxiMeilizhi> list = afterMingxiMeilizhiService.findList(map,splitPageBean);
            //明细类型
            Map<Integer,String> mingxiMap = Constants.getMingxiMap();
            request.setAttribute("mingxiMap",mingxiMap);
            request.setAttribute("list",list);
            request.setAttribute("splitPage",splitPageBean);
            request.setAttribute("startDate",startDate);
            request.setAttribute("endDate",endDate);
            request.setAttribute("nick",nick);
            request.setAttribute("phone",phone);
            return this.sucess("/web/after/mingxi/meilizhilist");
        }catch (Exception e){
            logger.error("收益明细列表异常",e);
            return this.error("系统繁忙");
        }
    }

    /**
     * 钻石明细
     * @param splitPageBean
     * @param startDate  开始时间
     * @param endDate  结束时间
     * @param nick  用户名称
     * @param phone  用户电话
     * @param giftname 礼物名称
     * @return
     */
    @RequestMapping("/zuanshiList")
    public String zuanshiList(SplitPageBean splitPageBean,String startDate,String endDate,String nick,String phone, String giftname){
        try{
            Map<String,Object> map = new HashMap<>();
            map.put("startDate",startDate);
            map.put("endDate",endDate);
            map.put("nick",nick);
            map.put("phone",phone);
            List<AppMingXiZuanShi> list = afterMingXiZuanShiService.findList(map,splitPageBean);
            //明细类型
            Map<Integer,String> mingxiMap = Constants.getMingxiMap();
            request.setAttribute("mingxiMap",mingxiMap);
            request.setAttribute("list",list);
            request.setAttribute("splitPage",splitPageBean);
            request.setAttribute("startDate",startDate);
            request.setAttribute("endDate",endDate);
            request.setAttribute("nick",nick);
            request.setAttribute("phone",phone);
            return this.sucess("/web/after/mingxi/zuanshilist");
        }catch (Exception e){
            logger.error("收益明细列表异常",e);
            return this.error("系统繁忙");
        }
    }


}
